#include <stdio.h>
#include <fcntl.h>
#include <assert.h>

int main() {
    int fd = open("data.txt", O_CREAT | O_WRONLY | O_TRUNC);
    assert(fd != -1);
    // 转int为FILE*指针
    FILE *fp = fdopen(fd, "w");
    fputs("aaaaaaaa\n", fp);
    int trans_fd = fileno(fp);
    printf("trans_fd = %d\n", trans_fd);
    fclose(fp);
    return 0;
}